import React, { Component } from 'react'
import PropTypes from 'prop-types'

class CourseItem extends Component {
    static propTypes = {
        stu: PropTypes.number,
        task: PropTypes.number.isRequired,
        name: PropTypes.string
    }

    //当属没传时，才使用默认值
    static defaultProps = {
        name: '同步课'
    }
    render() {
        const {stu, task, name} = this.props;

        //对象形式
        //const {data:{stu,task,name}} = this.props
        //const {stu,task,name} = this.props.data
        return (
            <div style={{width:200,border:'2px solid pink',marginTop:10,padding:10}}>
                <h2>{name}</h2>
                <p>任务数：{task}</p>
                <p>人数：{stu+1}</p>
                <button>申请</button>
            </div>
        )
    }
}
// CourseItem.propTypes = {
//     stu: PropTypes.number,
//     task: PropTypes.number.isRequired,
//     name: PropTypes.string
// }
export default CourseItem;